'use strict';

/* Controllers */

function notificationCtrl($scope,$http,$location,$stateParams) {
	$scope.isCollapsed = false;
	nexus.scheduleForm=$scope;
	
	$scope.sendMessage = function (){
	
			var ploc=$location.url();
			if(nexus.headerScope.notLogin){
				nexus.headerScope.turl=function(){
					//$location.path();
					$location.url(ploc);
				};
				nexus.headerScope.showLogin();
				return;
			}

	 var reqData = {"message" : $('#textmessage').val(), "toUser":{"id":$stateParams.id}};
	 var userListRef = new Firebase("https://th9d1ab33pb.firebaseio-demo.com/");
	 var myUserRef = userListRef.child($stateParams.id);
	 
	 $http.post('message', reqData).success(function(data) {
		 
		 myUserRef.set({ message: $('#textmessage').val()});
		 
		 alert("Message Posting "+data);
		//$location.path('/dashboard');
	});
	
		//}
	};
}
messageCtrl.$inject = ['$scope','$http','$location','$stateParams'];